<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title></title>
</head>

<body>
    <div>
        文本内容 水平和垂直居中 
    </div>
    <div>
        perseInt(3,8) 把8进制的3转换为10进制
    </div>
    <div>
        typeof 返回的是  string object number function undefiend boolean
    </div>
</body>

</html>
<script src="http://code.jquery.com/jquery-2.0.0.min.js"></script>
<script>
    // let a = 10;
    // let b = ++a - 1 + a++;
    // document.write(b + " " + a + "<br>");

    // // 计算2的n次幂
    // let n = parseInt(window.prompt("input"));
    /*   let mul = 1;
      for (let i = 0; i < n; i++) {
          mul *= 2;
      }
      document.write(mul + '<br>');

      计算阶乘
      document.write(n);
      let num = 1;
      for (let i = 0; i <= n; i++) {
          num *= i;
      }
      document.write(num); */

    // 输出三个书中最大的值
    /*     let z = parseInt(window.prompt('input'));
        let x = parseInt(window.prompt('input'));
        let y = parseInt(window.prompt('input'));

        if (z > x) {
             if (z > y) {
                document.write(z);
            }else{
                document.write(y);
            }
        }else{
            if (x > y) {
                document.write(x);
            }else{
                document.write(y);
            }
        } */

    // 斐波那楔数列

    /*     let first = 1,
            second = 1,
            end ;
        if (n > 2) {
            for (let i = 0; i < n-2; i++) {
                end = first + second;
                first = second;
                second = end
            }     
            document.write(end)
        }else{
            document.write(1);
        } */

    // 找出100以内的质数

    let count = 0;
    for (let j = 2; j < 100; j++) {

        for (let i = 1; i <= Math.sqrt(j); i++) {
            if (j % i === 0) {
                count++;
            }
        }
        if (count === 1) {
            document.write(j + "\n");
        }
        count = 0;
    }



    let x = 1, y = z = 0;
    function add(n){
        return n = n + 1;
    }
    y = add(x)
    function add(n) {
        return n = n + 3;
    }
    z = add(x)
    // 1 4 4

    // 穿一段字符串 查看字节长度

    var str = "ajdshkf as啊肯定会";
    function bytestLength(str){
        let num = 0;
        for(let i in str){
            if (str.charCodeAt(i) > 255) {
                num += 2;
            }else{
                num ++;
            }
        }
        return  num;
    }
    console.log(bytestLength(str));

    // 面试题练习

    function foo(){
        bar.appply(null,arguments)
    };
    function bar(){
        console.log(arguments);
    }
    foo(1,2,3,4,5)

    
    function b(x, y, a){
        arguments[2] = 10;
        alert(a)
    }
    b(1,2,3)
    
    function b1(x, y, a){
        a = 10;
        alert(arguments[2])
    }
    b1(1,2,3)


    let f = (
        function f() {
            return 1
        },
        function g (){
            return 2
        }
    ) ();
    typeof f;  //number


    let x = 1;
    if (function f(){}) {
        x+= typeof f;
    }
    console.log(x);


 
    function Person(name, age, sex){
        var a = 0;
        this.name = name;
        this.age = age;
        this.sex = sex;
        function sss(){
            a ++;
            console.log(a);
        }
        this.say = sss;
    }
    var oPerson = new Person();
    oPerson.say();
    oPerson.say()
    var oPerson1 = new Person();
    oPerson1.say();


    (function(x){
        delete x;
        return x;
    }(1))

    var h = function a (){
        return 23;
    }


    function retDate(date){
        var arr = ['一','二','三'];
        var ret = arr[date - 1];
        if (ret === undefined) {
            return 'error';
        }else{
            return ret;
        }
    }

    //一个字符串有a到z 请找出该字符串第一个只出现一次的字母
    // 字符串去重
</script>